from server.apps.main.logic.todo.validation import ValidTodoData
from server.apps.main.models import Todolist


def create(valid_data: ValidTodoData) -> Todolist:
    return Todolist.objects.create(
        title=valid_data.title,
        description=valid_data.description,
        is_done=valid_data.is_done
    )

def delete(check:list) -> None:
    Todolist.objects.filter(id__in=[int(_id) for _id in check]).delete()

def edit(id:int,valid_data: ValidTodoData) -> None:
    Todolist.objects.filter(id=id).update(title=valid_data.title,description=valid_data.description,is_done=valid_data.is_done)

def set_isdone(id:int) -> None:
       Todolist.objects.filter(id=id).update(is_done=True)